import 'package:flutter/material.dart';

///
///  GridView
///
///
///  网格布局是一种常见的布局类型，GridView 组件正是实现了网格布局的组件
/// https://api.flutter-io.cn/flutter/widgets/GridView-class.html
///
/// GridTile 针对网格布局封装好的子布局
///
/// https://api.flutter.dev/flutter/material/GridTile-class.html
///
///
class GridViewPage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return Scaffold(
        appBar: AppBar(
          title: Text("SingleChildScrollView"),
        ),
        body: getGridView02());
  }
}

getGridView01() {
  return GridView.count(
    primary: false,
    padding: const EdgeInsets.all(20),
    crossAxisSpacing: 10,
    mainAxisSpacing: 10,
    crossAxisCount: 2,
    children: <Widget>[
      Container(
        padding: const EdgeInsets.all(8),
        color: Colors.teal[100],
        child: const Text("He'd have you all unravel at the"),
      ),
      Container(
        padding: const EdgeInsets.all(8),
        color: Colors.teal[200],
        child: const Text('Heed not the rabble'),
      ),
      Container(
        padding: const EdgeInsets.all(8),
        color: Colors.teal[300],
        child: const Text('Sound of screams but the'),
      ),
      Container(
        padding: const EdgeInsets.all(8),
        color: Colors.teal[400],
        child: const Text('Who scream'),
      ),
      Container(
        padding: const EdgeInsets.all(8),
        color: Colors.teal[500],
        child: const Text('Revolution is coming...'),
      ),
      Container(
        padding: const EdgeInsets.all(8),
        color: Colors.teal[600],
        child: const Text('Revolution, they...'),
      ),
    ],
  );
}


getGridView02(){
  var sizeLenght=30;

  return GridView.builder(gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 2),
      itemBuilder: (_, int index){
     return InkWell(
       onTap: (){

       },
       child: GridTile(child:
           Image.asset("assets/images/8.jpeg")
        ,header: null,footer: Text("底部"),
       )
     );

},
  itemCount: sizeLenght,
  );


}